package tests;

import static org.junit.Assert.*;

import org.junit.Test;

import base.Arc;
import base.ShipSilhouette;
import base.ShipSilhouetteComparator;

public class ShipSilhouetteComparatorTest {

	@Test
	public void testConstructor() {
		ShipSilhouetteComparator c = new ShipSilhouetteComparator(0);
	}

	@Test
	public void testCompare() {
		ShipSilhouetteComparator c = new ShipSilhouetteComparator(0);
		ShipSilhouette s1, s2;
		
		s1 = createSilh(10,20);
		s2 = createSilh(15,25);
		
		// comparing to self
		assertTrue(c.compare(s1, s1) == 0);
		
		// simple comparison
		assertTrue(c.compare(s1, s2) < 0);
		assertTrue(c.compare(s2, s1) > 0);
		
		ShipSilhouette s3 = createSilh(10, 25);
		assertTrue(c.compare(s1, s3) == 0);
		
		s2 = createSilh(0,0);
		assertTrue(c.compare(s1, s2) > 0);
		
		s3 = createSilh(300, 330);
		assertTrue(c.compare(s1, s3) < 0);
		
		// comparing with angle that goes over the starting line
		s3 = createSilh(300, 30);
		assertTrue(c.compare(s1, s3) > 0);
		assertTrue(c.compare(s3, s1) < 0);
		
		s2 = createSilh(310, 40);
		assertTrue(c.compare(s3, s2) < 0);
		assertTrue(c.compare(s2, s3) > 0);
	}
	
	
	
	// comparisons are done based on the arc, so that's the only thing we're interested here
	protected ShipSilhouette createSilh(double beginAngle, double endAngle)
	{
		// Ship ship, Arc arc, Point2D.Double beginCorner, Point2D.Double endCorner, double[] distSquared
		return new ShipSilhouette (null, new Arc(beginAngle, endAngle), null,null,null);
	}

}
